package com.ruoyi.common.service.impl;

import com.ruoyi.common.domain.vo.TablePointVo;
import com.ruoyi.common.service.TableService;
import com.ruoyi.common.domain.vo.InitTableVo;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.customerService.enums.*;
import com.ruoyi.hqfinance.enums.HqInformStandardEndInformEnum;
import com.ruoyi.hqfinance.enums.HqInformStandardPlatformEnum;
import com.ruoyi.hqfinance.enums.HqInformStandardSheetEnum;
import com.ruoyi.hqfinance.enums.HqInformStandardSignTypeEnum;
import com.ruoyi.logistic.enums.NetworkUnderTakeEnum;
import com.ruoyi.qualityControl.domain.vo.QcInfoIndexExamineInTimeEnum;
import com.ruoyi.qualityControl.domain.vo.QcInfoIndexExamineIntegrityEnum;
import com.ruoyi.qualityControl.enums.*;
import com.ruoyi.statisticalCenter.enums.*;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

@Service
public class TableServiceImpl implements TableService {

    @Override
    public List<TableVo> initTable(InitTableVo initTableVo) {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = initTableVo.getFields();
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        switch (initTableVo.getCode()){
            case "inTimeSheet":
                for (TableVo vo : list) {
                    vo.setTranslate(QcInfoIndexExamineInTimeEnum.getValue(vo.getFields()));
                };
                break;
            case "integrity":
                for (TableVo vo : list) {
                    vo.setTranslate(QcInfoIndexExamineIntegrityEnum.getValue(vo.getFields()));
                };
                break;
            case "accuracy":
                for (TableVo vo : list) {
                    vo.setTranslate(QcInfoIndexExamineAccuracyEnum.getValue(vo.getFields()));
                };
                break;
            case "sheetCollect":
                for (TableVo vo : list) {
                    vo.setTranslate(HqInformStandardSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "collectSignType":
                for (TableVo vo : list) {
                    vo.setTranslate(HqInformStandardSignTypeEnum.getValue(vo.getFields()));
                };
                break;
            case "collectPlatform":
                for (TableVo vo : list) {
                    vo.setTranslate(HqInformStandardPlatformEnum.getValue(vo.getFields()));
                };
                break;
            case "collectEndInform":
                for (TableVo vo : list) {
                    vo.setTranslate(HqInformStandardEndInformEnum.getValue(vo.getFields()));
                };
                break;
            case "qcTimeExamineReceive":
                for (TableVo vo : list) {
                    vo.setTranslate(QcTimeExamineReceiveSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "qcTimeExamineStranded":
                for (TableVo vo : list) {
                    vo.setTranslate(QcTimeExamineStrandedSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "qcTimeExamineReturnGood":
                for (TableVo vo : list) {
                    vo.setTranslate(QcTimeExamineReturnGoodSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "qcTimeExamineSign":
                for (TableVo vo : list) {
                    vo.setTranslate(QcTimeExamineSignSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "csClaimsBillingRecords":
                for (TableVo vo : list) {
                    vo.setTranslate(CsClaimsBillingRecordsCollectEnum.getValue(vo.getFields()));
                };
                break;
            case "csCustomerComplaintSheetBill":
                for (TableVo vo : list) {
                    String value = CsCustomerComplaintSheetBillEnum.getValue(vo.getFields());
                    vo.setTranslate(CsCustomerComplaintSheetBillEnum.getValue(vo.getFields()));
                };
                break;
            case "csSheetHandleQuality":
                for (TableVo vo : list) {
                    vo.setTranslate(CsSheetHandleQualityEnum.getValue(vo.getFields()));
                };
                break;
            case "csSignRateUnStandard":
                for (TableVo vo : list) {
                    vo.setTranslate(CsSignRateUnStandardExamineEnum.getValue(vo.getFields()));
                };
                break;
            case "csClaimsBillingRecordsDetail":
                for (TableVo vo : list) {
                    vo.setTranslate(CsClaimsBillingRecordsDetailEnum.getValue(vo.getFields()));
                };
                break;

            case "ScHqSysHqBillOneEnum":
                for (TableVo vo : list) {
                    vo.setTranslate(ScHqSysHqBillOneEnum.getValue(vo.getFields()));
                };
                break;
            case "ScHqSysHqBillTwoEnum":
                for (TableVo vo : list) {
                    vo.setTranslate(ScHqSysHqBillTwoEnum.getValue(vo.getFields()));
                };
                break;
            case "scAssetsAndLiabilities":
                for (TableVo vo : list) {
                    vo.setTranslate(ScAssetsAndLiabilitiesEnum.getValue(vo.getFields()));
                };
                break;
            case "scWeight":
                for (TableVo vo : list) {
                    vo.setTranslate(ScWeightFlowStopEnum.getValue(vo.getFields()));
                };
                break;
            case "scOutPortWare":
                for (TableVo vo : list) {
                    vo.setTranslate(ScOutPortEnum.getValue(vo.getFields()));
                };
                break;
            case "scQuality":
                for (TableVo vo : list) {
                    vo.setTranslate(ScQualityEnum.getValue(vo.getFields()));
                };
                break;
            case "scOutReturn":
                for (TableVo vo : list) {
                    vo.setTranslate(ScOutReturnSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "scEnterPai":
                for (TableVo vo : list) {
                    vo.setTranslate(ScEnterPaiGrossProfitSheetEnum.getValue(vo.getFields()));
                };
                break;
            case "scOutBoundReturnSheetSet":
                for (TableVo vo : list) {
                    vo.setTranslate(ScOutBoundReturnSheetSetEnum.getValue(vo.getFields()));
                };
                break;
            case "areaIncome":
                for (TableVo vo : list) {
                    vo.setTranslate(NetworkUnderTakeEnum.getValue(vo.getFields()));
                };
                break;



        }
        return list;
    }

    @Override
    public List<TableVo> getFieldAnnotation(Object object) {
        Field[] fields = object.getClass().getDeclaredFields();
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        for (Field field : fields) {
            // 是否引用ApiModelProperty注解
            boolean bool = field.isAnnotationPresent(ApiModelProperty.class);
            if (bool) {
                String value = field.getAnnotation(ApiModelProperty.class).value();
                tableVo = new TableVo();
                tableVo.setFields(field.getName());
                tableVo.setTranslate(value);
                list.add(tableVo);
            }
        }
        return list;
    }

    @Override
    public List<TablePointVo> getFieldAnnotationTwo(Object object) {
        Field[] fields = object.getClass().getDeclaredFields();
        List<TablePointVo> list = new ArrayList<>();
        TablePointVo tableVo = new TablePointVo();
        for (Field field : fields) {
            // 是否引用ApiModelProperty注解
            boolean bool = field.isAnnotationPresent(ApiModelProperty.class);
            if (bool) {
                String value = field.getAnnotation(ApiModelProperty.class).value();
                tableVo = new TablePointVo();
                tableVo.setFields(field.getName());
                tableVo.setTranslate(value);
                list.add(tableVo);
            }
        }
        return list;
    }
}
